<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        #container div{
            height: 40px;
            width: 40px;
            border: solid 1px #0000ff;
            margin: 5px;
            float: left;
        }
    </style>
    <script src="jquery-1.11.2.min.js"></script>
    <script>
        $(function(){
            var $divs = $("#container div");
            var length = $divs.length;
            var i = 0;
            for( ;i < length ; i += 8){
                $($divs[i]).css("clear","both");
            }
        })
    </script>
</head>
<body>
    <div id="container">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
</html>